import 'dart:async';

import 'package:flutter/services.dart';

const MethodChannel _methodChannel =
MethodChannel('plugins.flutter.io/jpush_method');

const EventChannel _eventChannel =
EventChannel('plugins.flutter.io/jpush_event');


class JpushUtil {

  static StreamSubscription _counterSub;

  static void init(Function onData, Function onError) {
    if (_counterSub == null) {
      _counterSub = _eventChannel.receiveBroadcastStream().listen(
          onData, onError: onError);
    }
  }

  static void dispose() {
    if (_counterSub != null) {
      _counterSub.cancel();
    }
  }

  static void addTags() {
    _methodChannel.invokeMethod("addTag_ID");
  }

  static void removeTags() {
    _methodChannel.invokeMethod("removeTag_ID");
  }
}
